var sessionid =  sessionStorage.getItem("sessionid");
$(function() {
	$.ajax({
		type: "POST",
		url: "https://www.bjdeshangyuan.com/book/api/issue/list",
		data: {
			sessionid:sessionid,
			page: 1,
			pageSize: 10
		},
		success: function(data) {
			console.log("ajax接受成功")
			//获取的列表存放到一个变量里  减少代码量  方便书写
			var list = data.data.list
			console.log(list);
			var str = '';
			for (var i = 0; i < list.length; i++) {
				str += "<div class='problem'>"+
						    "<div class=' headlines'>"+
						      "<div class='headlines_title'>" + list[i].issueTitle + "</div>"+
						      "<div class='headlines_tdetails issueId' data-id='"+list[i].issueId+"'>详情</div>"+
						    "</div>"+
						    "<div class='initiator'>"+
						      "<div class='initiator_portrait'>"+
						        "<img src='"+list[i].headImgUrl+"'></img>"+
						      "</div>"+
						      "<div class='initiator_name'>发起人:"+list[i].nickName+"</div>"+
						    "</div>  "+
						    "<div class='i_summary'>&ensp;&ensp;&ensp;"+list[i].issueContent+"</div>"+
						    "<div class='launch_time'>"+
						      "<div class='launch_time_1'>发起时间："+list[i].issueCreatetime+"</div>"+
						      "<div class='participants'>参与人数:"+list[i].issueCount+"</div>"+
						    "</div>"+
					    "</div>"
			}
			$("#problem_warpper").html(str)
		}
	});
	$(document).on("click",".issueId",function(){
		//在渲染时给当前元素添加了一个自定义属性   属性是data-id  这个就是每一天评论的id编号 获取这个自定义属性
		var issueId = $(this).attr("data-id");
		//在跳转页面的时候把当前元素获取的自定义属性写在问号后面 
		//key(随便起的名字规范点) = value(自定义属性) 跳转就是把值直接带给下个页面了
		window.location.href="problem_details.html?issueId="+issueId+"&sessionid="+sessionid;
	})
	/* 跳转页面 */
	$("#me_submit").click(function() {
		window.location.href="we_submission.html?sessionid="+sessionid;
	})

	$('#back').click(function(){
		window.history.back()
	})
})